package top.tangyh.lamp.care.mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import top.tangyh.basic.base.mapper.SuperMapper;
import top.tangyh.lamp.care.entity.BExeYaoEvent;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>
 * Mapper 接口
 * 用药执行事件表
 * </p>
 *
 * @author zqb
 * @date 2024-07-26 10:31:52
 * @create [2024-07-26 10:31:52] [zqb] [代码生成器生成]
 */
@Repository
public interface BExeYaoEventMapper extends SuperMapper<BExeYaoEvent> {

    /**
     * 根据分组id
     * 分组id= groupId-planTime --> 10212323-2022-01-02 18:00:00
     *
     * @param groupId
     * @return
     */
    default List<BExeYaoEvent> selectListByGroupId(String groupId) {
        LambdaQueryWrapper<BExeYaoEvent> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(BExeYaoEvent::getGroupId, groupId);
        return this.selectList(queryWrapper);
    }

    /**
     * 根据用药id删除事件
     *
     * @param groupId
     */
    default void deleteByGroupId(String groupId) {
        LambdaUpdateWrapper<BExeYaoEvent> updateWrapper = new LambdaUpdateWrapper<>();
        updateWrapper.eq(BExeYaoEvent::getGroupId, groupId);
        this.delete(updateWrapper);
    }

}


